package com.df.bpm.utils.businessViewer.outputsDialogServices;

import com.df.bpm.entity.BusinessOutputs;
import com.df.bpm.utils.businessViewer.Main;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.web.client.RestTemplate;

public class BusinessOutputsService {


    public Integer updateOutput(BusinessOutputs businessOutputs) {
        if(businessOutputs.getBusinessInformationIndex()!=null
                && businessOutputs.getBusinessEntityIndex()!=null
        ){
            RestTemplate restTemplate = new RestTemplate();
            String url=Main.server+"businessOutputs/update";
            HttpEntity<BusinessOutputs> request = new HttpEntity<>(businessOutputs, null);
            ResponseEntity<?> response = restTemplate.exchange(
                    url,
                    HttpMethod.POST,
                    request, // 或者使用 HttpEntity 来添加请求头等信息
                    Integer.class
            );
            return (Integer) response.getBody();
        }
        return null;
    }

    public Integer delete(Integer businessOutputsIndex) {
        if(businessOutputsIndex!=null){
            RestTemplate restTemplate = new RestTemplate();
            String url=Main.server+"businessOutputs/delete?businessOutputsIndex="+businessOutputsIndex;
            ResponseEntity<?> response = restTemplate.exchange(
                    url,
                    HttpMethod.GET,
                    null, // 或者使用 HttpEntity 来添加请求头等信息
                    Integer.class
            );
            return (Integer) response.getBody();
        }
        return null;
    }
}
